package com.mall.b2c.domain.goods;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mall.common.domain.BaseEntity;

/**
 * 标签
 */
@Entity
@Table(name = "b2c_tag")
public class TagDomain extends BaseEntity {

	private static final long serialVersionUID = 530739203701330775L;

	private String name;// 标签名称
	@JsonIgnore 
	private Set<GoodsTagDomain> goodsTags;

	@Column(unique = true)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "tag")
	public Set<GoodsTagDomain> getGoodsTags() {
		return goodsTags;
	}

	public void setGoodsTags(Set<GoodsTagDomain> goodsTags) {
		this.goodsTags = goodsTags;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		TagDomain other = (TagDomain) obj;
		if (getId() == null) {
			if (other.getId() != null)
				return false;
		} else if (!getId().equals(other.getId()))
			return false;
		return true;
	}
}